<template>
	<div class="page">
		<c-title :hide="false" text="健康档案"></c-title>
		<div class="content">
			<div class="user_info">
				<div class="img_left">
					<img :src="member.avatar" alt="">
				</div>
				<div class="r">
					<div class="top">
					{{member.nickname}}
					</div>
					<div class="bot">
						<div class="sg">
							身高 175cm
						</div>
						<div class="tz">
							体重 76kg
						</div>
					</div>
					
				</div>
			</div>
			<div class="jcxx">
				基础信息
			</div>
			<div class="inpbox">
				<!-- <div class="item">
					  <van-field label-width="50" border v-model="name" label="姓名" placeholder="请输入姓名" />
					    <van-field label-width="50" v-model="nl" label="年龄" placeholder="请输入年龄" />
				</div> -->
				<!-- <div class="item">
					  <van-field label-width="50" v-model="xb" label="性别" placeholder="请输入性别"/>
					    <van-field label-width="50" v-model="jg" label="籍贯" placeholder="请输入籍贯"/>
				</div> -->
				
				<div class="item">
					  <van-field label-width="50" v-model="xm" label="姓名" placeholder="请输入姓名"/>
					    <van-field label-width="50" v-model="nl" label="年龄" placeholder="请输入年龄"/>
				</div>
				
				
				
				
				
				
				<div class="item">
					  <van-field label-width="50" v-model="sg" label="身高" placeholder="请输入身高"/>
					    <van-field label-width="50" v-model="tz" label="体重" placeholder="请输入体重"/>
				</div>
				<!-- <div class="item">
					  <van-field label-width="50" v-model="xt" label="血糖" placeholder="请输入血糖"/>
					    <van-field label-width="50" v-model="xy" label="血压" placeholder="请输入血压"/>
				</div> -->
			</div>
			<div class="gwbs">
				<!--  <van-field
				    v-model="gwbs"
				    rows="2"
				    autosize
				    label="过往病史"
				    type="textarea"
				    maxlength="50"
				    placeholder="请输入过往病史"
				    show-word-limit
				  /> -->
				
			</div>
			<div class="xyzz">
			<!-- 	<van-field
				  v-model="xyzz"
				  rows="2"
				  autosize
				  label="现有症状"
				  type="textarea"
				  maxlength="50"
				  placeholder="请输入现有症状"
				  show-word-limit
				/> -->
				
				<van-field
				  v-model="bqms"
				  rows="2"
				  autosize
				  label="病情描述"
				  type="textarea"
				  maxlength="50"
				  placeholder="请输入病情描述"
				  show-word-limit
				/>
				
				
				<van-field
				  v-model="gms"
				  rows="2"
				  autosize
				  label="过敏史"
				  type="textarea"
				  maxlength="50"
				  placeholder="请输入过敏史"
				  show-word-limit
				/>
				<van-field
				  v-model="hys"
				  rows="2"
				  autosize
				  label="婚育史"
				  type="textarea"
				  maxlength="50"
				  placeholder="请输入婚育史"
				  show-word-limit
				/>
				<van-field
				  v-model="jws"
				  rows="2"
				  autosize
				  label="既往史"
				  type="textarea"
				  maxlength="50"
				  placeholder="请输入既往史"
				  show-word-limit
				/>
				<van-field
				  v-model="jzs"
				  rows="2"
				  autosize
				  label="家族史"
				  type="textarea"
				  maxlength="50"
				  placeholder="请输入家族史"
				  show-word-limit
				/>
				<van-field
				  v-model="grs"
				  rows="2"
				  autosize
				  label="个人史"
				  type="textarea"
				  maxlength="50"
				  placeholder="请输入个人史"
				  show-word-limit
				/>
			</div>
			<div class="submit" @click="submit">
				提交
			</div>
		</div>
	</div>
</template>

<script>
	import {
		Toast
	} from 'vant';
	export default{
		data(){
			return{
				xm:'',
				nl:'',
				name:'',
				nl:'',
				xb:'',
				jg:'',
				sg:'',
				tz:'',
				xt:'',
				xy:'',
				bqms:'',
				gms:'',
				hys:'',
				jzs:'',
				jws:'',
				grs:'',
				gwbs:'',
				xyzz:'',
				member:{},
				id:""
			}
		},
		activated() {
			this.id = this.$route.query.id
			this.getdata()
			this.getMemberData()
		},
	methods:{
		getdata(){
			$http
				.post("plugin.hft-hospital.api.jiankang.get-base-data", {
					
				})
				.then(response => {
					console.log(response)
					if (response.result === 1) {
						this.sg = response.data.shengao
						this.tz = response.data.tizhong
						this.gms = response.data.guominshi
						this.bqms = response.data.bingqingmiaoshu
						
						this.hys = response.data.hunyushi
						this.jws = response.data.jiwangshi
						this.jzs = response.data.jiazushi
						this.grs = response.data.gerenshi
						
						this.xm = response.data.xingming
						this.nl = response.data.年龄
						
					} else {
						Toast(response.msg);
					}
				})
				.catch(error => {
					console.log(error);
				});
		},
		submit(){
			$http
				.post("plugin.hft-hospital.api.jiankang.submit-base-data", {
					shengao:this.sg,
					tizhong:this.tz,
					guominshi:this.gms,
					bingqingmiaoshu:this.bqms,
					hunyushi:this.hys,
					jiwangshi:this.jws,
					jiazushi:this.jzs,
					gerenshi:this.grs,
					xingming:this.xm,
					nianling:this.nl,
				})
				.then(response => {
					console.log(response)
					if (response.result == 1) {
						Toast(response.msg);
						console.log(11)
						this.$router.push(this.fun.getUrl("jstx", {}, { id:this.id }));
						// this.getdata()
					} else {
						// Toast(response.msg);
					}
				})
				.catch(error => {
					console.log(error);
				});
			
		},
		getMemberData() {
		  $http
		    .post("member.member.member-data", { v: 2,basic_info:1 }, " ")
		    .then(
		      response => {
		        if (response.result === 1) {
					this.member = response.data.member
		        } else {
		          Toast(response.msg);
		          this.template = "01";
		          require("@/assets/css/icon.scss");
		        }
		      },
		      response => {
		        console.log(response.msg);
		        require("@/assets/css/icon.scss");
		      }
		    )
		    .catch(err => {
		      console.error(err);
		      require("@/assets/css/icon.scss");
		    });
		},
	}
	}
</script>

<style scoped lang="scss">
	.page{
		.content{
			padding: 20upx;
			.submit{
				background-color: #169BD5;
				color: #fff;
				border-radius: 1rem;
				width: 90%;
				margin: 1rem auto;
				line-height: 2rem;
			}
			.inpbox{
				.item{
					display: flex;
					justify-content: space-between;
					van-field{
						width: 50%;
					}
				}
			}
			.jcxx{
				margin: 0.5rem 0;
			}
			.user_info{
				display: flex;
				background-color: #F2F2F2;
				border-radius: 0.5rem;
				padding: 0.5rem;
				.r{
					.bot{
						display: flex;
						.sg{
							margin-right: 0.5rem;
						}
					}
					.top{
						font-weight: 600;
						margin-bottom: 1.5rem	;
					}
				}
				.img_left{
					margin-right: 1rem;
					border-radius: 50%;
					img{
						width: 5rem;
						height: 5rem;
						border-radius: 50%;
					}
				}
			}
		}
	}
</style>